package com.airlines;

import org.apache.commons.lang.StringUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

 
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@ServletComponentScan
@EnableScheduling 
@Configuration 
@EnableAsync
public class WebApplicationBootstrap extends SpringBootServletInitializer {

	public static void main(String[] args) {
		long takes = System.currentTimeMillis();
		ApplicationContext ctx = SpringApplication.run(WebApplicationBootstrap.class, args);
		String port = ctx.getEnvironment().getProperty("server.port");

		String[] activeProfiles = ctx.getEnvironment().getActiveProfiles();

		System.err.println("profile:" + StringUtils.join(activeProfiles, ","));

		takes = System.currentTimeMillis() - takes;
		System.err.println(String.format("##Application started at %s. takes:%sms", port, takes));

	}
	
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(WebApplicationBootstrap.class);
	}
}
